function findTwoArrSum(arr1: number[], arr2: number[], sum: number) {
    if (!arr1 || !arr2) return false;

    let buffer = {};

    let arr_short, arr_long;
    if (arr1.length <= arr2.length) {
        arr_short = arr1;
        arr_long = arr2;
    } else {
        arr_short = arr2;
        arr_long = arr1;
    }
    for (let i = 0; i < arr_short.length; i ++) {
        const a1 = arr_short[i];
        buffer[sum - a1] = a1;
    }
    for (let i = 0; i < arr_long.length; i ++) {
        const a2 = arr_long[i];
        if (buffer[a2]) {
            console.log("存在元素: ", buffer[a2], a2)
            return true;
        }
    }
    return false;
}

function printFindTwoArrSum() {
    let a = [10, 40, 5, 280];
    let b = [234, 5, 2, 148, 23];
    let v = 42;
    let ret1 = findTwoArrSum(a, b, v);
    console.log(ret1)
}

printFindTwoArrSum();

// 两个数组各遍历一次，时间复杂度O(n), 空间复杂度为O(m), 其中m为两数组长度较小值，n为两数组长度较大值。